#ifndef _CITY_EDITOR_H_
#define _CITY_EDITOR_H_

#include "input/keyboard.h"
#include "input/mouse.h"
#include <string>
namespace LuaPlus
{
	class LuaState;	
}
namespace city
{

class CityEditor;
class	EditorBrush
{
public:
	EditorBrush(CityEditor* pEditor, const std::string& Name) : 
		m_pEditor(pEditor), m_Name(Name), m_Rotation(0) {};
	virtual ~EditorBrush() {};
	virtual void	Render() = 0;
	virtual void	Place() = 0;
	virtual void	SetPos(const math::Vec2& Pos) { m_Pos = Pos; };
	virtual bool	TryDelete(const math::Vec2& Pos) { return false; };		// see if we have any sub-components wants deleting
	virtual void	Raise(int Dir) { };
	virtual void	Toggle() {};
	virtual void	OnEnter() {};
	virtual void	Resize(const math::Vec2& Delta) {};
	virtual void	Rotate(int Dir)
	{
		if (Dir > 0) m_Rotation++;
		if (Dir < 0) m_Rotation--;
		if (m_Rotation < 0) m_Rotation = 3;
		if (m_Rotation > 3) m_Rotation = 0;
	};
	virtual void*	GetValue() { return NULL; };
protected:
	math::Vec2		m_Pos;
	CityEditor*		m_pEditor;
	std::string		m_Name;
	int				m_Rotation;
};


class CityMap;
class CityElement;
class CityEditor
{
public:
								CityEditor(CityMap* pScene);
								~CityEditor();
	void						Tick(float dt);
	void						Render();
	virtual void				Init();
	virtual void				Shutdown();


	void						AddNodeBrush(const std::string& Type);


	// input
	virtual	void				MouseButtonPressed(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);
	virtual void				MouseMove(const math::Vec2& From, const math::Vec2& To);
	virtual void				MouseWheelMove(int WheelInfo, const math::Vec2& Pos);
	virtual void				KeyPressed(input::Keyboard::KEY* pKey);
	virtual void				KeyDown(input::Keyboard::KEY* pKey);
	static	void				Register(LuaPlus::LuaState* _pScript);

	void						SetHelp(const std::string& Text) { m_HelpText = Text; };
	const math::Vec2&			GetMousePos() const { return m_MousePos; };
	CityMap*					GetScene() { return m_pScene; };
	void						ClearBrush();
private:
	CityMap*					m_pScene;
	EditorBrush*				m_pBrush;
	math::Vec2					m_MousePos;
	bool						m_SnapToGrid;
	std::string					m_HelpText;
	bool						m_ShowHelp;
};

};	//namespace city

#endif // _CITY_EDITOR_H_